import 'package:flutter/material.dart';

class Router {
  static const searchPage = 'app://SearchPage';

  Router.push(BuildContext context, String url, {dynamic params}) {
    Navigator.push(context, MaterialPageRoute(builder: (context) {
      if (params == null) {
        return _getPage(url, null);
      }
      return _getPage(url, params);
    }));
  }

  Widget _getPage(String url, dynamic params) {
    if (url.startsWith('https://') || url.startsWith('http://')) {
      return Center(
        child: Text('xxx'),
      );
    } else {
      switch (url) {
        case searchPage:
          return Scaffold(
            appBar: AppBar(title: Text('search'),),
            body: Center(
              child: Text('searchpage'),
            ),
          );
          break;
        default:
      }
      return Center(
        child: Text('xxx'),
      );
    }
  }
}
